﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;
using AjaxControlToolkit;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Web_Gpwf : System.Web.UI.Page
{
    private string num = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btnOK.Attributes.Add("onclick", "javascript:if(confirm('" + "确认无误，并提交么？" + "')== false) return false;");
            ddlNum.Items.Clear();
            ddlNum.Items.Add("请选择规格");
            DataSet ds = BLLFactory.CreateKcBLL().KuGBP(Session["用户信息.部门"].ToString());
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string guige = ds.Tables[0].Rows[i][0].ToString();
                ddlNum.Items.Add(guige);
            }
        }
    }
    public void ddlNum_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlNum.SelectedIndex != 0)
        {
            ddlNR.Visible = true;
            num = BLLFactory.CreateGpwfBLL().NumByKG(Session["用户信息.部门"].ToString(), ddlNum.SelectedValue.ToString());
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        int checkValue = 0;
        GpwfInfo wf = new GpwfInfo();
        wf.Num = num;
        wf.Neirong = ddlNR.SelectedValue.ToString();
        wf.Sl = Convert.ToDecimal(txtSL.Text.ToString());
        wf.Banzu = Session["用户信息.班组"].ToString();
        wf.Gday = DateTime.Now.ToString();
        string cday = DateTime.Now.ToShortDateString();
        wf.Gnum = BLLFactory.CreateGpwfBLL().AUTOID(Session["用户信息.部门"].ToString());
        checkValue = BLLFactory.CreateGpwfBLL().Add(wf);
        if (checkValue >= 1)
        {
            Response.Write(" <script   language=javascript> window.alert( ' 提交成功！ ');</script> ");
        }
        
        Response.Redirect(string.Format("GPWFJL.aspx?Banzu={0}&Cday={1}", wf.Banzu, cday));
    }
    protected void btnRepeat_Click(object sender, EventArgs e)
    {
        ddlNum.SelectedIndex = 0;
        txtSL.Text = "";
    }
}
